<div id="property_form">
	<h2>Add Condition</h2>
	<div class="content">
		<div class="form300">
			<?= Phpr_Form::openTag() ?>
				<? if (!isset($fatalError)): ?>
					<div class="form">
						<!--[if IE]><fieldset class="ie_fix"><![endif]-->
							<div class="formFlash"></div>
						<!--[if IE]></fieldset><![endif]-->

						<div class="form_page">
							<ul class="formElements">
								<li class="field dropdown full">
									<label for="ConditionType">Condition type</label>
									<div class="fieldContainer">
										<select name="condition_class" id="ConditionType">
											<option value="0">Please select a condition</option>
											<? foreach ($options as $name=>$class): ?>
												<? if (!is_array($class)): ?>
													<option value="<?= $class ?>"><?= h($name) ?></option>
												<? else: ?>
													<optgroup label="<?= h($name)?>">
														<? foreach ($class as $sub_name=>$sub_class): ?>
															<option value="<?= $sub_class ?>"><?= h($sub_name) ?></option>
														<? endforeach ?>
													</optgroup>
												<? endif ?>
											<? endforeach ?>
										</select>
									</div>
									<div class="clear"></div>
								</li>
							</ul>
							<div class="clear"></div>
						</div>
					</div>

					<?= backend_ajax_button('Create', $this->getEventHandler('onCreateCondition'), array(), "
						loadIndicator: {injectInElement: true},
						update: conditions_find_container('condition_".$condition->id."'),
						extraFields: $('condition_".$condition->id."').getForm(),
						preCheckFunction: function(){ 
							if ($('ConditionType').get('value') == 0)
							{
								alert('Please select condition.'); 
								$('ConditionType').focus();
								return false;
							}
							return true; 
						},
						onSuccess: function() {
							cancelPopup();
						},
						onAfterUpdate: function(){
							var new_id_element = conditions_find_new_id($('condition_".$condition->id."'));
							if (new_id_element)
								conditions_show_settings(new_id_element.value, '".$this->getEventHandler('onLoadConditionSetup')."')
						}
					") ?>
					<?= backend_button('Cancel', array('onclick'=>'return cancelPopup()')) ?>
				
					<div class="clear"></div>
					<input type="hidden" name="host_rule_set" value="<?= $condition->host_rule_set ?>"/>
					<!-- <input type="hidden" name="edit_session_key" value="<?= h($session_key) ?>"/> -->
					<!-- <input type="hidden" name="current_condition_id" value="<?= $condition->id ?>"/>
					<input type="hidden" name="conditions_root_id" value="<?= $conditions_root_id ?>"/> -->
				<? else: ?>
					<?= flash() ?>
					<?= backend_button('Cancel', array('onclick'=>'return cancelPopup()')) ?>
					<div class="clear"></div>
				<? endif ?>
			</form>
		</div>
	</div>
</div>